package com.heima.kaoshi1;

import java.io.*;
import java.util.Scanner;
import java.util.TreeSet;

public class PanXu {
    public static void main(String[] args) throws IOException {
//        键盘录入3个学生信息(姓名,语文成绩,数学成绩,英语成绩)。
        TreeSet<Student> students = new TreeSet<>();
        for (int i = 0; i < 3; i++) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入学生姓名：");
            String name = sc.next();
            System.out.println("请输入学生语文成绩：");
            int yuwen = sc.nextInt();
            System.out.println("请输入学生数学成绩：");
            int shuxue = sc.nextInt();
            System.out.println("请输入学生英语成绩：");
            int yingyu = sc.nextInt();
            int core = yuwen + shuxue + yingyu;
            students.add(new Student(name, yuwen, shuxue, yingyu, core));
//            for (Student student : students) {
//                System.out.println(student);
//            }
            BufferedWriter bu = new BufferedWriter(new FileWriter("mengjinling\\student.txt"));
            for (Student student : students) {
                bu.write(student.getName() + "," + student.getYuwengr() + "," + student.getShuxuegr() + "," + student.getYinyugr() + "," + student.getCore() + "\t\r");
            }
            bu.close();
            BufferedReader bf = new BufferedReader(new FileReader("mengjinling\\student.txt"));
            String line;
            while ((line = bf.readLine()) != null) {
                System.out.println(line);
            }
            bf.close();
        }

    }
}

